﻿using System;
using UnityEditor;
using UnityEngine;
using UnityEngine.U2D;

#if UNITY_EDITOR
public class EditorAtlasLoader : MonoBehaviour
{
    private void OnEnable()
    {
        SpriteAtlasManager.atlasRequested += RequestAtlas;
    }

    private void OnDisable()
    {
        SpriteAtlasManager.atlasRequested -= RequestAtlas;
    }

    private void RequestAtlas(string tag, Action<SpriteAtlas> callback)
    {
        var sa = AssetDatabase.LoadAssetAtPath<SpriteAtlas>($"Assets/ResourcesAssets/UI/GUI/{tag}.spriteatlas");
        callback(sa);
    }
}
#endif
